package com.niit.beans;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class Game implements InitializingBean, DisposableBean {
    public void play() {
        System.out.println("Playing Game");
    }
    @PostConstruct
    public void postConstruct(){
        System.out.println("自定义的方法：postConstruct");
    }
    @PreDestroy
    public void preDestroy(){
        System.out.println("自定义的方法：preDestroy");
    }
    public void myDestroy(){
        System.out.println("自定义的方法：myDestroy");
    }
    public void myInit(){
        System.out.println("自定义的方法：myInit");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        // TODO 实现你想要改变它生命周期的逻辑
        System.out.println("自定义的方法：afterPropertiesSet");
    }
    @Override
    public void destroy() throws Exception {
        // TODO 实现你想要改变它生命周期的逻辑
        System.out.println("自定义的方法：destroy()");
    }
}
